<%@ include file="../confHeader.jsp" %>
<%@ include file="../mensagens.jsp" %>
<html>
<head>
	
</head>
<body>

 <html:form  action="gruposAction" method="POST" onsubmit="return true;">
 	<html:hidden property="idGrupo" value="${to.id}"/> 		
 	<html:hidden property="nivel" value="${to.nivel}"/> 	
   <div class='pageForm'>
      <div class='formTitle'>  			
  			<bean:message key="${detail_title}"/>
      </div>        
        <div class='formField'>
            <label><bean:message key="grupo.nome"/></label>: &nbsp;
             ${el:write('to.nome',pageContext)}
        </div>          
          <div class='formField'>
            <label><bean:message key="grupo.descricao"/></label>: &nbsp;
	         ${el:write('to.descricao',pageContext)}
        </div>       
        <logic:equal name="to" property="temPai" value="true">
	         <div class='formField'>
	            <label><bean:message key="grupo.pai"/></label>: &nbsp;     
	              ${el:write('to.pai.nome',pageContext)}
	        </div>
    	 </logic:equal>
        <hr size="1">
          <div class='formButton'>           
            <a onclick="javascript:alterar();" class="linkButton">  <bean:message key="app.button.update"/></a>          
         		&nbsp;  
      		<a onclick="javascript:remover();" class="linkButton">   <bean:message key="app.button.delete"/></a>          
         		&nbsp;
           	<a onclick="javascript:popBack()" class="linkButton">   <bean:message key="app.button.return"/></a> 
         </div>    
                        
       <br>
        <logic:equal name="to" property="temFilhos" value="true">
            <div class='formTitle'>
  				<bean:message key="${list_title}"/>
            </div>            
    		<hr size="1">
            <div class='pageList'>
                <table cellspacing='0'>
                    <tbody>                       
                   	<bean:define id="filhosList" name="to" property="filhos" />     
		           <logic:present name="filhosList">
			            <logic:empty name="filhosList">
								<bean:message key="app.list.empty"/>
			            </logic:empty>
        			      <logic:notEmpty name="filhosList"> 
							 <tr class='thead'>					 	   
								 <td width="20%"><bean:message key="grupo.codigo"/>-<bean:message key="grupo.nome"/></td>
	                              <td width="40%"><bean:message key="grupo.descricao"/></td>
	                              <logic:equal name="to" property="temPai" value="true">
	                             	<td width="20%"><bean:message key="grupo.pai"/></td>
	                              </logic:equal>	     
	                        </tr>	                         
							<logic:iterate name='filhosList'  id="bean"  indexId="index" >									
 							   <tr class="${(index%2!=0)? 'shade' : ''}" onmouseover="this.className='mouseOver';" onmouseout="this.className='${(index%2!=0)? 'shade' : ''}'" >
	                             <td width="20%"><a href="javascript:detalhar('${bean.idGrupo}');"> ${el:write('bean.idGrupo',pageContext)} - ${el:write('bean.nome',pageContext)} </a></td>
	                              <td width="40%">${el:write('bean.descricao',pageContext)}</td>
	                               <logic:equal name="to" property="temPai" value="true">
		                             <td width="20%">${el:write('bean.pai.nome',pageContext)}</td>
                               	 </logic:equal>
    	                        </tr>
							</logic:iterate>
						</logic:notEmpty>
					</logic:present>                        
                    </tbody>     
                </table>      
            </div>

            </logic:equal>
    </div>
    </html:form>
   
      
<script type="text/javascript">
 // <!--
   
  var action= '<html:rewrite page="/gruposAction.do"/>';
  var nForm =  'GruposForm';

 function remover(){
	 if(confirm('<bean:message key="app.prompt.confirm.delete"/>\n<bean:message key="msg.07.01"/>')){
		 executeForm(nForm, action, 'remover');
	 }	 
 }
 
  function alterar(){	 
	 executeForm(nForm, action, 'goAltualizar');
 }
 
   function detalhar(id){
     document.forms[nForm].idGrupo.value = id;
 	 executeForm(nForm, action, 'goDetalhar');
 }
 
  //-->
</script>
</body>
</html>
